import request from '@/utils/request'

// 查询节点详情
export function getWfBusNode(id) {
  return request({
    url: '/node/wfBusNode/getWfBusNode/' + id,
    method: 'get'
  })
}

// 根据一级节点ID获取投前流程右侧的Card
export function getFirstNodeRightCardData(nodeId, businessId) {
  return request({
    url: '/node/wfBusNode/getFirstNodeRightCardData/' + nodeId + '/' + businessId,
    method: 'get'
  })
}

// 查询一级节点
export function getParentNode(busType, busId, roundId) {
  const queryData = {}
  queryData.busType = busType
  queryData.busId = busId
  queryData.roundId = roundId
  return request({
    url: '/node/wfBusNode/getParentNode',
    method: 'get',
    params: queryData
  })
}

// 查询二级节点
export function getChildrenNode(parentNodeId, busId, roundId) {
  const queryData = new FormData()
  queryData.busId = busId
  queryData.parentNodeId = parentNodeId
  queryData.roundId = roundId
  return request({
    url: '/node/wfBusNode/getChildrenNode',
    method: 'get',
    params: queryData
  })
}

// 获取form表单组件的地址
export function getNodeFormUrl(wfBusNode) {
  const queryData = new FormData()
  queryData.formType = wfBusNode.formType
  queryData.formId = wfBusNode.formId
  return request({
    url: '/node/wfBusNode/getNodeFormUrl',
    method: 'get',
    params: queryData
  })
}

// 绑定dataId
export function bindingDataId(id, dataId) {
  const data = new FormData()
  data.id = id
  data.dataId = dataId
  return request({
    url: '/node/wfBusNode/bindingDataId',
    method: 'get',
    params: data
  })
}

// 再次启动
export function restart(nodeData) {
  return request({
    url: '/node/wfBusNode/restart/' + nodeData.id,
    method: 'get'
  })
}

// 获取节点审批的历史记录
export function getHistoryApproval(id) {
  return request({
    url: '/node/wfBusNode/getHistoryApproval/' + id,
    method: 'get'
  })
}

// 获取节点审批的历史记录
export function checkCommitNextNode(id) {
  return request({
    url: '/node/wfBusNode/checkCommitNextNode/' + id,
    method: 'get'
  })
}

// 获取节点审批的历史记录
export function checkCommitNextNodeByBusId(busId) {
  return request({
    url: '/node/wfBusNode/checkCommitNextNodeByBusId/' + busId,
    method: 'get'
  })
}

// 提交至下一节点
export function commitNextNode(id) {
  return request({
    url: '/node/wfBusNode/commitNextNode/' + id,
    method: 'get'
  })
}

// 流程豁免
export function immunityProcess(id) {
  return request({
    url: '/node/wfBusNode/immunityProcess/' + id,
    method: 'get'
  })
}

// 获取首轮投资名称
export function getFirstInvestName(busId) {
  return request({
    url: '/node/wfBusNode/getFirstInvestName/' + busId,
    method: 'get'
  })
}

// 保存投资轮次
export function saveInvestRound(data) {
  return request({
    url: '/node/wfBusNode/saveInvestRound',
    method: 'post',
    params: data
  })
}
